package com.tianhui.consignortwofei.mvp.model;

import android.content.Context;

import com.fgs.common.CommonModel;
import com.fgs.common.api.CommonConfig;
import com.fgs.common.progress.ObserverResponseListener;
import com.tianhui.consignortwofei.api.AccountApiService;
import com.tianhui.consignortwofei.mvp.model.enty.RegisterInfo;

import java.util.Map;

import io.reactivex.ObservableTransformer;

/**
 * @author fgs
 * @date 2020/3/27
 **/
public class AccountModel<T> extends CommonModel {

    public void loginModel(Context context, Map<String, String> map, boolean isDialog,
                           ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(AccountApiService.class).login(map), observerListener, transformer, isDialog, true);
    }

    public void loginModelGet(Context context, Map<String, String> map, boolean isDialog,
                           ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(AccountApiService.class).loginGet(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 货主注册
     *
     * @param context
     * @param info
     * @param isDialog
     * @param cancelable
     * @param transformer
     * @param observerListener
     */
    public void registerModel(Context context, RegisterInfo info, boolean isDialog, boolean cancelable,
                              ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(AccountApiService.class).register(info), observerListener, transformer, isDialog, cancelable);
    }
}
